<?php
namespace Home\Controller;
use Think\Controller;

class CartController extends Controller
{
    public function add(){
        $model = D('cart');
//        var_dump(I('post.',1));die();
        if(IS_POST){
          if($model->create(I('post.',1))){
              if($model->add()){
                  $this->success('添加成功',U('Home/Cart/checkout'));
                  exit();
              }
              $this->error('添加失败'.$model->getError().$model->getLastSql());
          }
        }
        $this->assign();
        $this->display();
    }

    public function checkout(){
        $cart = D('cart');
        $cartdata = $cart->checkout();
        $this->assign(array(
            'cartdata' => $cartdata,
        ));
        $this->display();
    }
}

?>